// let base_url="http://www.normalword.com:4000"
let base_url = "http://59.110.91.222:4000"

// 定义了一个$reqeust的网络请求方法
let $request = function(url, data = {}, method = 'get') {
	uni.showLoading({
		title: '正在加载'
	})
	return new Promise((resolve, reject) => {
		uni.request({
			url: base_url + url,
			data,
			method,
			success(res) {
				resolve(res.data)
			},
			fail(err) {
				reject(err)
			},
			complete() {
				uni.hideLoading()
			}
		})
	})
}


// 将baseurl
uni.$base_url = base_url
uni.$request = $request
uni.$get = function(url, data) {
	return $request(url, data)
}

uni.$post = function(url, data) {
	return $request(url, data, "POST");
}
uni.$delete = function(url, data) {
	return $request(url, data, "DELETE");
}
uni.$put = function(url, data) {
	return $request(url, data, "PUT");
}